package org.example.basic.entity;



import org.example.basic.util.ChineseNameUtil;

import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;

/**
 * @author songyafei
 */
public class UserEntityList {

    private final static int MAX_SIZE = Integer.MAX_VALUE;
    private final static int DEFAULT_SIZE = 100;

    private static int s ;

    private static List<UserEntity> item = new ArrayList<>(s);

    public UserEntityList(int size){
        s = size;
    }

    static {
        clear();
        if( 0 == s) {s = DEFAULT_SIZE;}
        for (int i = 0; i < s; i++) {
            item.add(new UserEntity(Long.valueOf(i), i, ChineseNameUtil.getName(),
                    LocalDate.now().minusYears(i),
                    Double.valueOf(i*10)));
        }
    }

    public static List<UserEntity> getList(){
        return item;
    }

    private static void clear(){
        if(item.size()>=MAX_SIZE){
            item.clear();
        }
    }

    public static List<UserEntity> getItem(){
        List<UserEntity> L = new ArrayList<UserEntity>();
        L.add(new UserEntity(1L, 17, ChineseNameUtil.getName(), LocalDate.now().minusYears(1),Double.valueOf(3000)));
        L.add(new UserEntity(2L, 12, ChineseNameUtil.getName(), LocalDate.now().minusYears(2),Double.valueOf(3500)));
        L.add(new UserEntity(3L, 14, ChineseNameUtil.getName(), LocalDate.now().minusYears(3),Double.valueOf(4000)));
        L.add(new UserEntity(4L, 27, ChineseNameUtil.getName(), LocalDate.now().minusYears(1),Double.valueOf(3400)));
        L.add(new UserEntity(5L, 18, ChineseNameUtil.getName(), LocalDate.now(),Double.valueOf(6000)));
        L.add(new UserEntity(6L, 19, ChineseNameUtil.getName(), LocalDate.now(),Double.valueOf(6500)));
        L.add(new UserEntity(7L, 22, ChineseNameUtil.getName(), LocalDate.now().minusYears(1),Double.valueOf(7000)));
        L.add(new UserEntity(8L, 30, ChineseNameUtil.getName(), LocalDate.now(),Double.valueOf(8000)));
        L.add(new UserEntity(9L, 34, ChineseNameUtil.getName(), LocalDate.now().minusYears(3),Double.valueOf(9000)));
        L.add(new UserEntity(10L, 26, ChineseNameUtil.getName(), LocalDate.now().minusYears(4),Double.valueOf(13000)));
        return L;
    }


}
